$OpenBSD: patch-memcached_c,v 1.11 2016/09/02 14:20:31 giovanni Exp $
--- memcached.c.orig	Fri Jun 24 19:41:24 2016
+++ memcached.c	Thu Jun 30 00:02:09 2016
@@ -23,6 +23,7 @@
 #include <sys/uio.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <unistd.h>
 
 /* some POSIX systems need the following definition
  * to get mlockall flags out of sys/mman.h.  */
@@ -6100,6 +6101,32 @@ int main (int argc, char **argv) {
 
     if (pid_file != NULL) {
         save_pid(pid_file);
+    }
+
+    if (settings.socketpath != NULL) {
+        if (pid_file != NULL) {
+           if (pledge("stdio cpath unix", NULL) == -1) {
+              fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
+              exit(1);
+           }
+        } else {
+           if (pledge("stdio unix", NULL) == -1) {
+              fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
+              exit(1);
+           }
+        }
+    } else {
+        if (pid_file != NULL) {
+           if (pledge("stdio cpath inet", NULL) == -1) {
+              fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
+              exit(1);
+           }
+        } else {
+           if (pledge("stdio inet", NULL) == -1) {
+              fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
+              exit(1);
+           }
+        }
     }
 
     /* Drop privileges no longer needed */
